package com.xbongbong.paas.enums;




import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * BI团队相关的枚举（可能不包含所有）
 *
 * @author 梁鲁江
 */
@Getter
public enum BITeamEnum {
    /**
     *
     */
    CUSTOMER_TEAM(XbbRefTypeEnum.CUSTOMER_TEAM.getCode(),XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), XbbRefTypeEnum.CUSTOMER_TEAM.getAlias()),
    CONTRACT_TEAM(XbbRefTypeEnum.CONTRACT_TEAM.getCode(), XbbRefTypeEnum.CONTRACT.getCode(),XbbRefTypeEnum.CONTRACT_TEAM.getAlias()),
    CONTACT_TEAM(XbbRefTypeEnum.CONTACT_TEAM.getCode(),XbbRefTypeEnum.CONTACT.getCode(), XbbRefTypeEnum.CONTACT_TEAM.getAlias()),
    PAYMENT_TEAM(XbbRefTypeEnum.PAYMENT_TEAM.getCode(), XbbRefTypeEnum.PAYMENT.getCode(),XbbRefTypeEnum.PAYMENT_TEAM.getAlias()),
    PRODUCTION_ORDER_TEAM(XbbRefTypeEnum.PRODUCTION_ORDER_TEAM.getCode(), XbbRefTypeEnum.PRODUCTION_ORDER.getCode(),XbbRefTypeEnum.PRODUCTION_ORDER_TEAM.getAlias()),
    PAY_PLAN_TEAM(XbbRefTypeEnum.PAY_PLAN_TEAM.getCode(), XbbRefTypeEnum.PAY_PLAN.getCode(), XbbRefTypeEnum.PAY_PLAN_TEAM.getAlias()),
    SALES_OPPORTUNITY_TEAM(XbbRefTypeEnum.SALES_OPPORTUNITY_TEAM.getCode(), XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(),XbbRefTypeEnum.SALES_OPPORTUNITY_TEAM.getAlias()),
    BOM_BILL_TEAM(XbbRefTypeEnum.BOM_BILL_TEAM.getCode(), XbbRefTypeEnum.BOM_BILL.getCode(),XbbRefTypeEnum.BOM_BILL_TEAM.getAlias()),
    PURCHASE_TEAM(XbbRefTypeEnum.PURCHASE_TEAM.getCode(), XbbRefTypeEnum.PURCHASE.getCode(),XbbRefTypeEnum.PURCHASE_TEAM.getAlias()),
//    SUPPLIER_CONTACT_TEAM(XbbRefTypeEnum.SUPPLIER_CONTACT_TEAM.getCode(), XbbRefTypeEnum.SUPPLIER_CONTACT_TEAM.getAlias()),
    SUPPLIER_TEAM(XbbRefTypeEnum.SUPPLIER_TEAM.getCode(), XbbRefTypeEnum.SUPPLIER.getCode(),XbbRefTypeEnum.SUPPLIER_TEAM.getAlias()),
    //不同
//    PRODUCT_TEAM(XbbRefTypeEnum.PRODUCT_TEAM.getCode(), XbbRefTypeEnum.PRODUCT_TEAM.getAlias()),
    REFUND_TEAM(XbbRefTypeEnum.REFUND_TEAM.getCode(),XbbRefTypeEnum.REFUND.getCode(), XbbRefTypeEnum.REFUND_TEAM.getAlias()),
    WORK_ORDER_TEAM(XbbRefTypeEnum.WORK_ORDER_TEAM.getCode(), XbbRefTypeEnum.WORK_ORDER.getCode(),XbbRefTypeEnum.WORK_ORDER_TEAM.getAlias()),
    QUOTATION_TEAM(XbbRefTypeEnum.QUOTATION_TEAM.getCode(), XbbRefTypeEnum.QUOTATION.getCode(),XbbRefTypeEnum.QUOTATION_TEAM.getAlias()),
    CLUE_TEAM(XbbRefTypeEnum.CLUE_TEAM.getCode(), XbbRefTypeEnum.CLUE.getCode(),XbbRefTypeEnum.CLUE_TEAM.getAlias()),
    MARKET_ACTIVITY_TEAM(XbbRefTypeEnum.MARKET_ACTIVITY_TEAM.getCode(), XbbRefTypeEnum.MARKET_ACTIVITY.getCode(),XbbRefTypeEnum.MARKET_ACTIVITY_TEAM.getAlias()),
    ;


    /**
     * 枚举值 --
     */
    private final Integer code;
    /**
     * 父文档的枚举值
     */
    private final Integer parentCode;

    /**
     * 枚举描述 --英文名称
     */
    private final String alias;

    /**
     * 构造一个<code>XbbRefTypeEnum</code>枚举对象
     *
     * @param code  枚举Code
     * @param alias 枚举别名
     */
    BITeamEnum(Integer code, Integer parentCode, String alias) {
        this.code = code;
        this.parentCode = parentCode;
        this.alias = alias;
    }

    /**
     * 通过枚举 alias 获得枚举
     *
     * @param alias 枚举别名
     *
     * @return XbbRefTypeEnum
     */
    public static BITeamEnum getByAlias(String alias) {
        for (BITeamEnum cacheCode : values()) {
            if (cacheCode.getAlias().equals(alias)) {
                return cacheCode;
            }
        }
        return null;
    }

    /**
     * 通过枚举 code 获得枚举
     *
     * @param code 枚举Code
     *
     * @return XbbRefTypeEnum
     */
    public static BITeamEnum getByCode(Integer code) {
        for (BITeamEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return null;
    }

    /**
     * 获取全部枚举
     *
     * @return List<XbbRefTypeEnum>
     */
    public static List<BITeamEnum> getAllEnum() {
        List<BITeamEnum> list = new ArrayList<>();
        for (BITeamEnum cache : values()) {
            if (cache == null) {
                continue;
            }
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取全部枚举值
     *
     * @return List<String>
     */
    public List<String> getAllEnumAlis() {
        List<String> list = new ArrayList<>();
        for (BITeamEnum cache : values()) {
            if (cache == null) {
                continue;
            }
            list.add(cache.getAlias());
        }
        return list;
    }

    /**
     * 获取所有code值
     * @return
     */
    public static List<Integer> getAllEnumCode() {
        List<Integer> list = new ArrayList<>();
        for (BITeamEnum cache : values()) {
            if (cache == null) {
                continue;
            }
            list.add(cache.getCode());
        }
        return list;
    }

    /**
     * 根据parentCode获取枚举
     * @param parentCode
     * @return
     */
    public static BITeamEnum getByParentCode(Integer parentCode) {
        for (BITeamEnum cacheCode : values()) {
            if (cacheCode.getParentCode().equals(parentCode)) {
                return cacheCode;
            }
        }
        return null;
    }
}
